<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
Copyright 2004 ThoughtWorks, Inc

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<html>
<head>
    <meta content="text/html; charset=ISO-8859-1"
          http-equiv="content-type">
    <title>Test Cookie</title>
</head>
<body>
    
    <p>WARNING! You can only run this test off of a "real" webserver (i.e. over http); you can't run this test directly off of the file system.</p>
    <p>Also note that the paths used in this test don't have to actually exist; we can get 404 errors on every one of these pages but still successfully test the cookie functionality.</p>
<table cellpadding="1" cellspacing="1" border="1">
    <tbody>
        <tr>
            <td rowspan="1" colspan="3">Test Cookie<br>
            </td>
        </tr>
        <tr>
            <td>storeEval</td>
            <td>parseUrl(canonicalize(absolutify("html", selenium.browserbot.baseUrl))).pathname;</td>
            <td>base</td>
        </tr>
        <tr>
            <td>echo</td>
            <td>${base}</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path1/cookie1.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>deleteAllVisibleCookies</td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td>assertCookie</td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path2/cookie2.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>deleteAllVisibleCookies</td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td>assertCookie</td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
    </tbody>
</table>

<table cellpadding="1" cellspacing="1" border="1">
    <tbody>
        <tr>
            <td>open</td>
            <td>${base}/path1/cookie1.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>createCookie</td>
            <td>addedCookieForPath1=new value1</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>createCookie</td>
            <td>addedCookieForPath2=new value2</td>
            <td>path=${base}/path2/, max_age=60</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path1/cookie1.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookie</td>
            <td>regex:addedCookieForPath1=new value1</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>assertCookiePresent</td>
            <td>addedCookieForPath1</td>
            <td></td>
        </tr>
        <tr>
            <td>verifyCookieByName</td>
            <td>addedCookieForPath1</td>
            <td>new value1</td>
        </tr>
        <tr>
            <td>verifyCookieNotPresent</td>
            <td>testCookie</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookieNotPresent</td>
            <td>addedCookieForPath2</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>deleteCookie</td>
            <td> addedCookieForPath1</td>
            <td>${base}/path1/</td>
        </tr>
        <tr>
            <td>verifyCookie</td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path2/cookie2.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookieByName</td>
            <td>addedCookieForPath2</td>
            <td>new value2</td>
        </tr>
        <tr>
            <td>verifyCookieNotPresent</td>
            <td>addedCookieForPath1</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>deleteCookie</td>
            <td> addedCookieForPath2</td>
            <td>${base}/path2/</td>
        </tr>
        <tr>
            <td>verifyCookie</td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
    </tbody>
</table>

Testing creating cookies with same name but diffrent paths
<table cellpadding="1" cellspacing="1" border="1">
    <tbody>
        <tr>
            <td>createCookie</td>
            <td>testCookieWithSameName=new value1</td>
            <td>path=/</td>
        </tr>
        <tr>
            <td>createCookie</td>
            <td>testCookieWithSameName=new value2</td>
            <td>path=${base}/path2/</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path1/cookie1.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookieByName</td>
            <td>testCookieWithSameName</td>
            <td>new value1</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path2/cookie2.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookie</td>
            <td>regex:testCookieWithSameName=new value1</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookie</td>
            <td>regex:testCookieWithSameName=new value2</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>deleteCookie</td>
            <td> testCookieWithSameName</td>
            <td>${base}/path2/</td>
        </tr>
        <tr>
            <td>open</td>
            <td>${base}/path2/cookie2.html</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>verifyCookieByName</td>
            <td>testCookieWithSameName</td>
            <td>new value1</td>
        </tr>
        <tr>
            <td>verifyNotCookie</td>
            <td>regex:testCookieWithSameName=new value2</td>
            <td>&nbsp;</td>
        </tr>
    </tbody>
</table>

</body>
</html>
